<?php require_once 'header.php';?>    
<!-- DataTables Responsive CSS -->
    <link href="sb2/vendor/datatables-responsive/dataTables.responsive.css" rel="stylesheet">

        <!-- Page Content -->
        <div id="page-wrapper">
            <div class="container-fluid">
            <div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                        <?php echo XXF_BACK?>
                            教师管理 <br>
                            [
                            <input type="text" id="workunit" name="x" placeholder="单位"  title="单位" value="重庆煤矿安全技术培训中心" style="font-size: 10px;width:150px;">
                            <input type="text" id="tname" name="x" placeholder="姓名" title="姓名" style="font-size: 10px;width:80px;">
                            <select id="sex" name="x"><option>男</option><option>女</option></select>
                            <input type="text" id="shengri" name="x" placeholder="出生年月" title="出生年月" style="font-size: 10px;width:80px;">
                            <input type="hidden" id="mphone" name="x" placeholder="手机" title="手机" style="font-size: 10px;width:80px;">
                            <input type="text" id="biyeschool" name="x" placeholder="毕业学校" title="毕业学校"  style="font-size: 10px;width:80px;">
							<input type="text" id="zhuanye" name="x" placeholder="专业" title="专业" style="font-size: 10px;width:80px;">
                            <input type="text" id="zhicheng" name="x" placeholder="职称" title="职称"  style="font-size: 10px;width:80px;">
                            <input type="text" id="wenhua" name="x" placeholder="学历" title="学历"  style="font-size: 10px;width:80px;">
                            <input type="hidden" id="zhuanyeage" name="x" placeholder="专业从事日期" title="专业从事日期"  style="font-size: 10px;width:80px;">
                            <input type="hidden" id="jiaoxueage" name="x" placeholder="教学从事日期" title="教学从事日期"  style="font-size: 10px;width:80px;">
                            <input type="button" id="add" value="添加" onclick="add()"> ]
                        </div>
                        <!-- /.panel-heading -->
                        <div class="panel-body">
                            <table width="100%" class="table table-striped table-bordered table-hover" id="dataTables-example">
                                <thead>
                                    <tr>
                                        <th>教师姓名</th>
                                        <th>教师信息</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                	<?php
                                	$i=0;
                                	foreach ($result as $row){$i++;
                                	?>
                                    <tr class="<?php echo $i%2==0?"even":"odd";?> gradeA" id='<?php echo $row['id'];?>'>
                                        <td><?php echo $row['tname'];?></td>
                                        <td>
                                        	<?php echo $row['sex'];?>
                                        	<?php echo $row['workunit'];?>
                                        	<?php echo $row['biyeschool'];?>
                                        	<?php echo $row['zhuanye'];?>
                                        	<?php echo $row['zhicheng'];?>
                                        	<?php echo $row['shengri'];?>
                                        	<?php echo $row['wenhua'];?>
                                        </td>
                                        <td><a href="javascript:del(<?php echo $row['id']?>)">删除</a></td>
                                    </tr>
                                	<?php 
                                	}
                                	?>
                                </tbody>
                            </table>
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                </div>
                <!-- /.col-lg-12 -->
            
            <!-- /.row -->
             </div>
        </div>
        <!-- /#page-wrapper -->
  </div>
        <!-- DataTables JavaScript -->
<?php require_once 'bottom.php';?>
    <script src="sb2/vendor/datatables/js/jquery.dataTables.js"></script>
    <script src="sb2/vendor/datatables-plugins/dataTables.bootstrap.min.js"></script>
    <script src="sb2/vendor/datatables-responsive/dataTables.responsive.js"></script>
    <script>
    
    $(document).ready(function() {
        $('#dataTables-example').DataTable({
            responsive: true,
            "aaSorting": [[ 0, "desc" ]],
            "aLengthMenu": [ 100,50,25,10]
        });
        $("#shengri").click(function(){$(this).xrili();});
        $("#zhuanyeage").click(function(){$(this).xrili();});
        $("#jiaoxueage").click(function(){$(this).xrili();});
    });
   
    function del(id){
		$.xconfirm("删除后无法恢复，确定要删除此条记录么？",function(data){
 			if(data){
				$.xloading(1);
				$.xtodb("del","peixunjiaoshi",{},id,function(data1){
					if(data1==0){
						$.xloading(0);
						$.xalert("删除失败");
					}else{
						window.location.reload();
					}
				});
			} 
		});
    }
     function add(){
    	var tname = $("#tname").val();
 		if(tname.length<2){
			$.xalert("名字必须填写！");return false;
 	 	}
    	$.xconfirm("确定添加？",function(data){
 			if(data){
				$.xloading(1);
				$.xtodb("add","peixunjiaoshi",$("[name='x']"),"tname",function(data1){
					if(data1==0){
						$.xloading(0);
						$.xalert("添加失败");
					}else{
						window.location.reload();
					}
				});
			} 
		});
    }     
    </script>